package core.service;

import core.dao.CategoryDAO;
import core.entity.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Christian Waickem on 9/22/2014.
 */
@Service
@Transactional(readOnly = true)
public class CategoryService {

    @Autowired
    CategoryDAO categoryDAO;
    
    @Transactional
    public void createTopic(Category category){
        categoryDAO.createTopic(category);
    }

    @Transactional
    public void deleteTopic(Category category){
        categoryDAO.deleteCategory(category);
    }

    @Transactional
    public void updateTopic(Category category){
        categoryDAO.updateCategory(category);
    }

    public Category findTopic(long id){
        return categoryDAO.findCategory(id);
    }

    public List<Category> getAllCategories(){
        return categoryDAO.getAllCategories();
    }
}
